package com.fanghaoran.notes.bean;

import java.util.List;
import java.util.Map;

/**
 * @Author: win11
 * @Date: 2023/04/18/21:53
 * @Description: 展示商品数据页的类
 */
public class Page<T> {
    private List<T> list;
    private int currentPage;
    private int pageSize;
    private Long totalCount;
    private int totalPage;

    public Page() {
    }

    public Page(List<T> list, int currentPage, int pageSize, Long totalCount) {
        this.list = list;
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
    }

    /**
     * 获取
     *
     * @return list
     */
    public List<T> getList() {
        return list;
    }

    /**
     * 设置
     *
     * @param list 商品数据集合
     */
    public void setList(List<T> list) {
        this.list = list;
    }

    /**
     * 获取
     *
     * @return currentPage
     */
    public int getCurrentPage() {
        return currentPage;
    }

    /**
     * 设置
     *
     * @param currentPage 当前页
     */
    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    /**
     * 获取
     *
     * @return pageSize
     */
    public int getPageSize() {
        return pageSize;
    }

    /**
     * 设置
     *
     * @param pageSize 每页条数
     */
    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    /**
     * 获取
     *
     * @return totalCount
     */
    public Long getTotalCount() {
        return totalCount;
    }

    /**
     * 设置
     *
     * @param totalCount 总额
     */
    public void setTotalCount(Long totalCount) {
        this.totalCount = totalCount;
    }

    /**
     * 获取
     *
     * @return totalPage
     */
    public int getTotalPage() {
        //总页数 向上取余
        return (int) Math.ceil(totalCount * 1.0 / pageSize);
    }

    /**
     * 设置
     *
     * @param totalPage 总页数
     */
    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    @Override
    public String toString() {
        return "Page{list = " + list + ", currentPage = " + currentPage + ", pageSize = " + pageSize + ", totalCount = " + totalCount + ", totalPage = " + totalPage + "}";
    }
}
